﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Interview_Prov.Controls.Answers;

namespace Interview_Prov.Controls
{
    public partial class AnswerCheckBox : System.Web.UI.UserControl
    {
        public bool Checked { get { return answer_ctl.Checked;} }
        public string AnswerLabel { get; set; }
        public bool EditMode { get; set; }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            answer_edit.Text = AnswerLabel;
            answer_label.Text = AnswerLabel;

            if (EditMode)
            {
                answer_helper.Visible = true;
                answer_label.Visible = false;
                answer_ctl.Visible = false;
                answer_edit.Visible = true;
                answer_delete.Visible = true;
            }
        }

        public event EventHandler<AnswerEventArgs> DeleteClicked;
        public int AnswerIndex { get; set; }
        protected void answer_delete_Click(object sender, EventArgs e)
        {
            if (DeleteClicked != null)
            {
                DeleteClicked(sender, new AnswerEventArgs(this.AnswerIndex));
            }
        }

        public event EventHandler<AnswerEventArgs> AnswerValueChanged;
        protected void answer_edit_TextChanged(object sender, EventArgs e)
        {
            if (AnswerValueChanged != null)
            {
                AnswerValueChanged(sender, new AnswerEventArgs(this.AnswerIndex, this.answer_edit.Text));
            }
            AnswerLabel = this.answer_edit.Text;
        }
        


    }
}